package controller;

import pojo.Book;
import service.BookService;
import view.BookClassification;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

public class BookClassificationListener implements ActionListener {
    private BookClassification bookClassification;
    private BookService bookService = new BookService();
    public BookClassificationListener(BookClassification bookClassification){
        this.bookClassification=bookClassification;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals("马列主义毛泽东思想")){
            List<Book> bookList = bookService.searchClassify("马列主义毛泽东思想");
            bookClassification.setBookList(bookList);
            bookClassification.refresh1();
        }
        if(e.getActionCommand().equals("哲学")){
            List<Book> bookList = bookService.searchClassify("哲学");
            bookClassification.setBookList(bookList);
            bookClassification.refresh1();
        }
        if(e.getActionCommand().equals("社会科学")){
            List<Book> bookList = bookService.searchClassify("社会科学");
            bookClassification.setBookList(bookList);
            bookClassification.refresh1();
        }
        if(e.getActionCommand().equals("自然科学")){
            List<Book> bookList = bookService.searchClassify("自然科学");
            bookClassification.setBookList(bookList);
            bookClassification.refresh1();
        }
        if(e.getActionCommand().equals("综合性图书")){
            List<Book> bookList = bookService.searchClassify("综合性图书");
            bookClassification.setBookList(bookList);
            bookClassification.refresh1();
        }
    }
}
